package main.java.indi.zyj.coderecord;

public class SortArrayByParityII {

    public int[] sortArrayByParityII(int[] nums) {

        int j = 1;

        for (int i = 0; i < nums.length - 1; i += 2) {
            if ((nums[i] & 1) != 0) {
                while ((nums[j] & 1) != 0) {
                    j += 2;
                }
                int temp = nums[i];
                nums[i] = nums[j];
                nums[j] = temp;
            }
        }

        return nums;

    }

}
